package com.bi.autotest.pages.payprocesspage;

import com.auto.base.PageAppium;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

/**
 * Created by yidian on 2018/4/23.
 */
public class NewCScanBPage extends PageAppium {

    public final String IMG_COMMONQRCODE_XP = "//*[@id='qrcode-bottom']/img";//android.widget.Image[@content-desc='wx_help']/following-sibling::android.widget.Image[1]";  //*[@id="qrcode-bottom"]/img
    public final String SETMONEY_XP = "//android.widget.Button[@content-desc='设置金额']";
    /**
     * 设置金额,选定商品，付款/html/body/div/div/div[1]/div[1]/div[2]/
     */
    public final String SETMONEY_H5_XP = "//button[contains(text(), '设置金额')]";
    public final String GOODS_INPUTS = "//*[@id='goods_inputs']/a";//添加商品
    public final String GOODS_ADD_BUTTON_1 = "//*[@id='li0']//*[@class='add goods-add']";//第一个商品增加按钮
    public final String SURE_ADD_BUTTON = "//*[@class='button sure']";//第一个商品增加按钮
    public final String QRCODE_MONEY_XP = "//*[@id='qrcode-bottom']/p[3]";//设置的实际金额 //p[@class='money'][1]
    public final String GOODS_COUNT_XP = "//*[@id='code']/following::a[1]";//设置的实际金额
    public final String PAY_AMOUNT_XP = "//*[@id='payAmount']";//输入框显示金额
    public final String BOX_XP = "//div[@class='box']";//输入键盘
    public final String DESCRIBE_XP = "//div[@class='item-title'][1]";//描述商品数量和订单金额"共1件商品，订单金额:￥3.00"
    public final String GOODS_NAME_XP = "//div[@class='storeName']";//商品名称
    public final String SURE_PAY_BUTTON = "//*[@id='submissionSub']";//商品名称
    /** //*[@id="qrcode-bottom"]/p[3]
     * 识别二维码
     */
    public final String CHOOSE_QRCODE_XP = "//android.widget.TextView[@text='识别图中二维码']";
    public final String POP_UP_MESSAGE_XP = "//android.widget.TextView[@text='识别图中二维码']";
    public final String VIP_PAY_XP = "//button[@id='button-card-submit']";//会员卡付款按钮

    public final String POP_UP_MESSAGE_NULL ="//div[contains(text(), '商家还没有给你优惠哟')]";
    public final String POP_UP_MESSAGE_TYPE = "/html/body/div/div/div[3]/div/div[1]/div[3]/div[1]";//优惠类别（主显示）
    public final String POP_UP_MESSAGE_LIMIT = "/html/body/div/div/div[3]/div/div[1]/div[3]/div[2]";//优惠额度（主显示）
    public final String POP_UP_MESSAGE_2 = "/html/body/div/div/div[3]/div/div[1]/div[4]";//优惠第二条

    public final String POP_BUTTON_XP = "//*[@id='down']/span";//弹出账单详情按钮

    /**
     *  支付前确认支付账单详情XPath
     */
    public final String PRE_PAY_ORDER_XP = "//*[@id=\"orderAmount2\"]";//订单金额数据
    public final String PRE_PAY_LJJ_XP = "//*[@id='wxOrAliDisplayNoneComs']";//消费立减数据
    public final String PRE_PAY_DISCOUNT_XP = "//*[@id='orderDiscountAmount']";//折扣特权数据
    public final String PRE_PAY_VIPPRICE_XP = "//*[@class='item-after goodsVip']";//会员价优惠
    public final String PRE_PAY_VIPCARD_XP = "/html/body/div[1]/div/div[2]/div/div[1]/div[2]/div/div[4]/div/div[2]";//会员卡余额抵扣（相对定位）
    public final String PRE_PAY_MONEY_XP = "//*[@id='vipAmount']";//付款金额
    public final String PRE_PAY_SELLER_XP = "//*[@id='card-Name']";//商户名称 XXX卡支付
    public final String PRE_PAY_BUTTON_XP = "//*[@id='button-card-submit']";//XXX付款按钮

    /**
     *  支付完成账单详情XPath
     */
    public final String PAY_MONEY_XP = "/html/body/div/div/div/section/div/p[1]";//支付金额详情
    public final String PAY_STATE_XP = "/html/body/div/div/div/section/div/p[2]";//账单状态详情
    public final String PAY_PRIMECOST_XP = "/html/body/div/div/div/section/div/div[1]/ul[1]/li[1]/div/div[2]";//订单原价详情
    public final String PAY_PREFERENTIAL_1_XP = "/html/body/div/div/div/section/div/div[1]/ul[1]/li[2]/div/div[2]";//订单原价下面， 第一项（优惠）注：字段获取控件可能会因改变而失败
    public final String PAY_PREFERENTIAL_2_XP = "/html/body/div/div/div/section/div/div[1]/ul[1]/li[3]/div/div[2]";//订单原价下面， 第二项（优惠）
    public final String PAY_PREFERENTIAL_3_XP = "/html/body/div/div/div/section/div/div[1]/ul[1]/li[4]/div/div[2]";//订单原价下面， 第三项（优惠）
    public final String PAY_METHOD_XP = "/html/body/div/div/div/section/div/div[1]/ul[2]/li[1]/div/div[1]";//支付方式：微信支付,XXX卡支付
    public final String PAY_WEIXIN_MONEY_XP = "/html/body/div/div/div/section/div/div[1]/ul[2]/li[1]/div/div[2]";//所用支付方式，支付的金额
    public final String VIPCARD_MONEY_XP = "/html/body/div/div/div/section/div/div[1]/ul[2]/li[1]/div[2]";//会员卡余额 (会员卡余额￥80.00)


    public final String CHECK_BENEFIT_XP = "//*[@id='fnishButton']";//账单页面，查看权益按钮

    public final String REMARK_ID = "//*[@resource-id='input_msg']";
    public final String PAYTYPE_XP = "//*[@resource-id='selectedPayType']";
    public final String PAYTYPE_XP2 = "//*[contains(@text()," + "会员卡" + ")]";//

    public final String SMALL_CHANGE = "//android.widget.TextView[contains(@text,'零钱')]";

    public final String VIPCARDPAY_BUTTON_XP = "//android.widget.Button[@content-desc='会员卡付款']";



    public final String PAYSUCCESS_TEXT_TEXT = "付款成功";
    // public final String COMPLETE_XP="//android.widget.Button[@content-desc='完 成']";
    public final String ARROW_DOWN_XP = "//android.view.View[@resource-id='down']";
    public final String VIP_PAYTYPE_XP = "//android.view.View[@content-desc='选择支付方式']/following-sibling::android.view.View[2]";
    //  public final String CANCEL_BUTTON_XP="//android.view.View[@content-desc='取消']";
    public final String RESULT_REMARK_XP = "//*[contains(@text()," + "中国红" + ")]";
    // public final String WXPAY_BUTTON_ID="button-card-submit";
    public final String PAY_RIGHTAWAY_XP = "//android.widget.Button[@resource-id='com.tencent.mm:id/dyg']";
    public final String CLOSE_MSH_XP = "//a[contains(text(), '去付款')]";

    public final String SETMONEY_CONFIRM_XP = "//android.widget.Button[@content-desc='确认 支付']";
    public final String SET_ADDGOODS_XP = "//android.view.View[@content-desc='添加商品点这里']";
    public final String SET_INPUTMONEY_XP = "//android.view.View[@content-desc='请输入有效金额']";
    public final String SETEFFECT_CONFIRMBUTTON_XP = "//android.view.View[@content-desc='确定']";
    public final String SET_KEYCODEDEL_XP = "//android.widget.Button[@content-desc='确认']/preceding-sibling::android.widget.Button";
    public final String CLEAR_MONEY_XP = "//android.widget.Button[@resource-id='clearAmount']";

    //设置金额后的自助付款
    public final String SET_SUBMISSION_XP = "//android.widget.Button[@resource-id='submissionSub']";
    //选择商品页面的元素
    public final String ADDXWZ_BUTTON_XP = "//android.view.View[@content-desc='章鱼小丸子']/following-sibling::android.widget.Button";
    public final String CONFIRM_ADD_XP = "//android.widget.Button[@content-desc='确认添加']";
    //左侧的关闭按钮
    public final String LEFT_CLOSE_ID = "com.tencent.mm:id/hy";
    //故宫门店名
    public final String GG_STORE_XP = "//android.view.View[@content-desc='故宫']";
    //qwer门店名
    public final String QWER_STORE_XP = "//android.view.View[@content-desc='qwer']";
    public final String STORE_BUTTON_XP = "//android.widget.Image[@content-desc='wx_help']/../preceding-sibling::android.view.View";
    //超市门店名
    public final String CS_STORE_XP = "//android.view.View[@content-desc='超市']";
    //消费立减的文字
    public final String LIJIAN_TEXT_XP = "//android.view.View[@content-desc='消费立减']";
    //0.01元的文字
    public final String SMALL_JINE_TEXT_XP = "//android.view.View[@content-desc='¥0.01']";
    //折扣特权文字
    public final String ZHEKOU_TEXT_XP = "//android.view.View[@content-desc='1折特权']";
    //申请开通的文字
    public final String APPLY_FLAVOR_XP = "//android.view.View[@content-desc='申请开通']";
    public final String BTN_XP = "//div[@class='box']/div/button[@disabled]";//原型：//title[@lang]选取所有拥有名为lang的属性的title 元素。


    public NewCScanBPage(AndroidDriver androidDriver) {
        super(androidDriver);
    }

    public AndroidElement getCommonQRCodeImg() {
        return waitAutoByXp(IMG_COMMONQRCODE_XP);
    }

    public AndroidElement getChooseQRCode() {
        return waitAutoByXp(CHOOSE_QRCODE_XP);
    }

    public AndroidElement getPayTypeButton() {
        return waitAutoByXp(PAYTYPE_XP2);
    }

    public boolean isExistVipCardPayButton() {
        return isXpathExist(VIPCARDPAY_BUTTON_XP);
    }

    public AndroidElement getDownButton() {
        return waitAutoByXp(ARROW_DOWN_XP);
    }

    public AndroidElement getRemarkInputArea() {
        return waitAutoByXp(REMARK_ID);
    }

    public boolean isExistResultRemarkText() {
        return isXpathExist(RESULT_REMARK_XP);
    }

    public boolean isExistPayRightAwayButton() {
        return isXpathExist(PAY_RIGHTAWAY_XP);
    }

    public AndroidElement getMSHCloseButton() {
        return waitAutoByXp(CLOSE_MSH_XP, 5);
    }

    //设置金额
    public AndroidElement getSetMoneyButton() {
        return waitAutoByXp(SETMONEY_H5_XP);
    }

    public boolean isExistSetMoneyText() {
        return isXpathExist(SETMONEY_XP);
    }

    public AndroidElement getGoodsInputs() {
        return waitAutoByXp(GOODS_INPUTS);
    }

    public AndroidElement getGoodsAddButton1() {
        return waitAutoByXp(GOODS_ADD_BUTTON_1);
    }

    public AndroidElement getSureAddButton() {
        return waitAutoByXp(SURE_ADD_BUTTON);
    }

    public boolean isQRcodeMoney(String text) {
        return isPageContainsText(text);
    }

    public boolean isGoodsCount(String text) {
        return isXpathExistText(GOODS_COUNT_XP,text,5);
    }

    public boolean isPayAmount(String text) {
        return isXpathExistText(PAY_AMOUNT_XP,text,5);
    }

    /**
     *输入金额键盘不存在，即不可输入
     */
    public boolean isNoInput() {
        return !isXpathExist(BOX_XP);
    }

    public boolean isDescribe(String text) {
        return isXpathExistText(DESCRIBE_XP,text,5);
    }

    public boolean isGoodsName(String text) {
        return isXpathExistText(GOODS_NAME_XP,text,5);
    }

    public AndroidElement getSurePayButton() {
        return waitAutoByXp(SURE_PAY_BUTTON);
    }

    public AndroidElement getSetConfirmButton() {
        return waitAutoByXp(SETMONEY_CONFIRM_XP);
    }

    public AndroidElement getAddGoodsButton() {
        return waitAutoByXp(SET_ADDGOODS_XP);
    }

    public boolean isExistInputMoneyText() {
        return isXpathExist(SET_INPUTMONEY_XP);
    }

    public AndroidElement getSetEffectConfirmButton() {
        return waitAutoByXp(SETEFFECT_CONFIRMBUTTON_XP);
    }

    //获取设置金额键盘上的删除键
    public AndroidElement getSetDelButton() {
        return waitAutoByXp(SET_KEYCODEDEL_XP);
    }

    public boolean isExistClearText() {
        return isXpathExist(CLEAR_MONEY_XP);
    }

    public AndroidElement getSetClearButton() {
        return waitAutoByXp(CLEAR_MONEY_XP);
    }

    public AndroidElement getSetSubmissionButton() {
        return waitAutoByXp(SET_SUBMISSION_XP);
    }

    public AndroidElement getElementByName(String name) {
        return waitAutoByName(name);
    }

    public boolean isExistElementByName(String name) {
        return isTextElementExist(name);
    }

    public AndroidElement getAddXWZButton() {
        return waitAutoByXp(ADDXWZ_BUTTON_XP);
    }

    public AndroidElement getConfirmAddButton() {
        return waitAutoByXp(CONFIRM_ADD_XP);
    }

    public AndroidElement getLeftCloseButton() {
        return waitAutoById(LEFT_CLOSE_ID);
    }

    public AndroidElement getStoreButton() {
        return waitAutoByXp(STORE_BUTTON_XP);
    }

    public AndroidElement getQWERButton() {
        return waitAutoByXp(QWER_STORE_XP);
    }

    public AndroidElement getGGButton() {
        return waitAutoByXp(GG_STORE_XP);
    }

    public AndroidElement getCSButton() {
        return waitAutoByXp(CS_STORE_XP);
    }

    public boolean isExistLiJianText() {
        return isXpathExist(LIJIAN_TEXT_XP);
    }

    public boolean isExistSmallJineText() {
        return isXpathExist(SMALL_JINE_TEXT_XP);
    }

    public boolean isExistZheKouText() {
        return isXpathExist(ZHEKOU_TEXT_XP);
    }

    public boolean isExistUnOpenText() {
        return isXpathExist(APPLY_FLAVOR_XP);
    }

    //是否存在灰色确认支付按钮，Class属性值中包含字符串"disabled"
    public boolean isExistBtnClass() {
        return isXpathExist(BTN_XP);
    }

    //更换支付选择零钱控件
    public AndroidElement getSmallChange() {
        return waitAutoByXp(SMALL_CHANGE, 5);
    }

    public AndroidElement getVipPay() {
        return waitAutoByXp(VIP_PAY_XP, 5);
    }

    /**
     * 码上恵弹窗 主显示 无优惠是否正确
     */
    public boolean isPopUpMessageNull() {
        return isXpathExist(POP_UP_MESSAGE_NULL, 5);
    }

    /**
     * 码上恵弹窗 主显示 优惠类型是否是正确
     *
     * @param type 优惠类型
     */
    public boolean isPopUpMessageType(String type) {
        return isXpathExistText(POP_UP_MESSAGE_TYPE, type, 5);
    }

    /**
     * 码上恵弹窗 主显示 优惠额度是否正确
     *
     * @param limit 额度
     */
    public boolean isPopUpMessageLimit(String limit) {
        return isXpathExistText(POP_UP_MESSAGE_LIMIT, limit, 5);
    }

    /**
     * 码上恵弹窗显示优惠是否正确_第二条
     *
     * @param text 额度
     */
    public boolean isPopUpMessage2(String text) {
        return isXpathExistText(POP_UP_MESSAGE_2, text, 5);
    }

    /**
     * 支付前，确认账单
     *      订单金额数据，是否正确
     */
    public boolean isPrePayDrder(String text) {
        boolean a = isXpathExistText(PRE_PAY_ORDER_XP, text, 5);
        return a ;
    }

    /**
     * 支付前，确认账单
     *      折扣，是否正确
     */
    public boolean isPrePayDiscount(String text) {
        boolean b = isXpathExistText(PRE_PAY_DISCOUNT_XP, text, 5);
        return  b;
    }

    /**
     * 支付前，确认账单
     *      会员价优惠，是否正确
     */
    public boolean isPrePayVipPrice(String text) {
        boolean b = isXpathExistText(PRE_PAY_VIPPRICE_XP, text, 5);
        return  b;
    }

    /**
     * 支付前，确认账单
     *      消费立减数据，是否正确
     */
    public boolean isPrePayLJJ(String text) {
        boolean b = isXpathExistText(PRE_PAY_LJJ_XP, text, 5);
        return  b;
    }

    /**
     * 支付前，确认账单
     *      会员卡余额抵扣，是否正确
     */
    public boolean isPrePayVipCard(String text) {
        boolean b = isXpathExistText(PRE_PAY_VIPCARD_XP, text, 5);
        return  b;
    }

    /**
     * 支付前，确认账单
     *      付款金额数据，是否正确
     */
    public boolean isPrePayMoney(String text) {
        boolean c = isXpathExistText(PRE_PAY_MONEY_XP, text, 5);
        return  c;
    }

    /**
     * 支付前，确认账单
     *      商户名称 XXX卡支付，是否正确
     */
    public boolean isPrePaySeller(String text) {
        boolean d = isXpathExistText(PRE_PAY_SELLER_XP, text, 5);
        return  d;
    }

    /**
     * 支付前，确认账单
     *      XXX付款，付款按钮是否正确
     */
    public boolean isPrePayButton(String text) {
        boolean e = isXpathExistText(PRE_PAY_BUTTON_XP, text, 5);
        return  e;
    }
    /**
     * 支付完成，账单详情
     *      支付金额详情，是否正确
     */
    public boolean isPayMoney(String text) {
        boolean a = isXpathExistText(PAY_MONEY_XP, text, 5);
        return  a;
    }

    /**
     * 支付完成，账单详情
     *     账单状态详情，是否正确
     */
    public boolean isPayState(String text) {
        boolean b = isXpathExistText(PAY_STATE_XP, text, 5);
        return  b;
    }

    /**
     * 支付完成，账单详情 第一项
     *      订单原价详情，是否正确
     */
    public boolean isPayPrimecost(String text) {
        boolean c = isXpathExistText(PAY_PRIMECOST_XP, text, 5);
        return  c;
    }

    /**
     * 支付完成，账单详情 第一项优惠， 是否正确
     *
     */
    public boolean isPayPreferential_1(String text) {
        boolean d = isXpathExistText(PAY_PREFERENTIAL_1_XP, text, 5);
        return  d;
    }

    /**
     * 支付完成，账单详情 第二项优惠， 是否正确
     *
     */
    public boolean isPayPreferential_2(String text) {
        boolean d2 = isXpathExistText(PAY_PREFERENTIAL_2_XP, text, 5);
        return  d2;
    }

    /**
     * 支付完成，账单详情  支付方式， 是否正确
     *
     */
    public boolean isPayMethod(String text) {
        boolean e = isXpathExistText(PAY_METHOD_XP, text, 5);
        return  e;
    }

    /**
     * 支付完成，账单详情 微信支付金额， 是否正确
     *
     */
    public boolean isPayWeiXinMoney(String text) {
        boolean e = isXpathExistText(PAY_WEIXIN_MONEY_XP, text, 5);
        return  e;
    }

    /**
     * 支付完成，账单详情 会员卡余额， 是否正确
     *
     */
    public boolean isVipCardMoney(String text) {
        boolean e = isXpathExistText(VIPCARD_MONEY_XP, text, 5);
        return  e;
    }

    /**
     * 支付完成账单页面 查看权益 按钮
     */
    public AndroidElement getCheckBenefitButton() {
        return waitAutoByXp(CHECK_BENEFIT_XP);
    }

}
